package com.egobuy.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.egobuy.entity.ItemCat;

import com.egobuy.pojo.BuyResult;
import com.egobuy.product.mapper.ItemCatMapper;
import com.egobuy.product.service.IItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品类目 服务实现类
 * </p>
 *
 * @author Hello
 * @since 2021-11-22
 */
@Service
public class ItemCatServiceImpl extends ServiceImpl<ItemCatMapper, ItemCat> implements IItemCatService {
@Autowired
private ItemCatMapper itemCatMapper;
    @Override
    public BuyResult<List<ItemCat>> queryByParentId(int parentId) {
        BuyResult<List<ItemCat>> result=BuyResult.ok();

        QueryWrapper<ItemCat> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_id",parentId);
        List<ItemCat> itemCats = itemCatMapper.selectList(queryWrapper);
        result.setData(itemCats);
        return result;
    }
}
